package cn.stylefeng.guns.modular.system.service;

import cn.stylefeng.guns.core.shiro.ShiroKit;
import cn.stylefeng.guns.modular.system.entity.SysSchoolAgent;
import cn.stylefeng.guns.modular.system.mapper.SysSchoolAgentMapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 学校与代理人关联表 服务类
 * </p>
 *
 * @author zfy
 * @since 2020-08-11
 */
@Service
public class SysSchoolAgentService extends ServiceImpl<SysSchoolAgentMapper,SysSchoolAgent> {
    public String getSchoolByAgent (){
        SysSchoolAgent one = this.getOne(new QueryWrapper<SysSchoolAgent>()
                .select("GROUP_CONCAT(school_user_id) remarks")
                .eq("agent_user_id", ShiroKit.getUserNotNull().getId()));
        return one != null? one.getRemarks():"";
    }

    public SysSchoolAgent getAgentBySchool (Long userId){
        return this.getOne(new QueryWrapper<SysSchoolAgent>().eq("school_user_id",userId));
    }
}
